//-----------------------------------------------------------------------
// <copyright file="HistoryServiceBase.cs" company="Pyramid Consulting">
//     Copyright (c) Pyramid Consulting. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------	

using System;
using System.Collections;
using Pyco;
using Pyco.Diagnostics;
using Pyco.Data;
using BirthdayReminder.Entities;
using BirthdayReminder.Data;
    
namespace BirthdayReminder.Business
{   
	/// <summary>
	/// 
	/// </summary> 
    public class HistoryServiceBase
    {
        #region HistoryServiceBase

        public static void CreateHistory(History history)
        {            
            try
            {
                HistoryDAO historyDAO = new HistoryDAO();
                historyDAO.CreateHistory(history);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessCreateHistoryException, ex);
            }
        }

        public static void UpdateHistory(History history)
        {            
            try
            {
                HistoryDAO historyDAO = new HistoryDAO();
                historyDAO.UpdateHistory(history);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessUpdateHistoryException, ex);
            }
        }        

        public static void DeleteHistory(int historyId)
        {            
            try
            {
                HistoryDAO historyDAO = new HistoryDAO();
                historyDAO.DeleteHistory(historyId);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessDeleteHistoryException, ex);
            }
        }
		
        public static History GetHistory(int historyId)
        {            
            try
            {
                HistoryDAO historyDAO = new HistoryDAO();
                return historyDAO.GetHistory(historyId);                
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetHistoryException, ex);
            }
        }                
		
        public static HistoryCollection GetHistoryList(HistoryColumns orderBy, OrderDirection orderDirection)
        {            
            try
            {
                HistoryDAO historyDAO = new HistoryDAO();
                return historyDAO.GetHistoryList(orderBy, orderDirection);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetHistoryListException, ex);
            }
        }        

        public static HistoryCollection GetHistoryList(HistoryColumns orderBy, OrderDirection orderDirection, int page, int pageSize, out int totalRecords)
        {            
            try
            {
                HistoryDAO historyDAO = new HistoryDAO();
                return historyDAO.GetHistoryList(orderBy, orderDirection, page, pageSize, out totalRecords);
            }
            catch (BusinessException)
            {
                throw;
            }
            catch (Exception ex)
            {
                // log this exception
                Logger.Error(ex);
                // wrap it and rethrow
                throw new BusinessException(SRBase.BusinessGetHistoryListException, ex);
            }
        }        
		
		
        #endregion
    }
}